/*
Authors:
Matthew Kretsch
Erich Perrault
Vanh Her
*/
#include "DirectXFramework.h"
#include "DirectSound.h"
#include "GraphicalEntity.h"

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE prevInstance, PSTR cmdLine, int showCmd)
{
	UNREFERENCED_PARAMETER(prevInstance);
	UNREFERENCED_PARAMETER(cmdLine);
	UNREFERENCED_PARAMETER(showCmd);

#ifdef _DEBUG
	_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
	//_CrtSetBreakAlloc(177);
#endif
	//Application code here
	CDirectXFramework *DirectXFramework = NULL;
	_Globals *nGlobals = NULL;
	DirectXFramework = new CDirectXFramework(hInstance, "Conglomeration", D3DDEVTYPE_HAL, D3DCREATE_HARDWARE_VERTEXPROCESSING);
	
	nGlobals = new _Globals();
	Globals = nGlobals;

	_Random *NRandom = new _Random();
	Random = NRandom;

	DirectXFramework->LoadEntities();

	gd3dApp = DirectXFramework;
	
	DirectInput di(DISCL_NONEXCLUSIVE|DISCL_FOREGROUND, DISCL_NONEXCLUSIVE|DISCL_FOREGROUND);
	gDInput = &di;
	//DirectSound ds(DSSCL_EXCLUSIVE, 1);
	//gDSound = &ds;

	if(gd3dDevice && gd3dApp)
		DirectXFramework->run();

	delete DirectXFramework;
	delete Globals;
	delete Random;
	
	/*if(gDSound)
	{
		delete gDSound;
		gDSound = NULL;
	}*/

#ifdef _DEBUG
	_CrtDumpMemoryLeaks();
#endif
	return 0;
}